package com.example.demo.Controller;

import com.example.demo.bean.shop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
@RestController
@Api(tags="商品管理")
@RequestMapping("/shop")
public class shopController {
    @Autowired
    private com.example.demo.service.shopService shopService;

    /**
     * 添加信息
     * @param@RequestParam("shopid") int shopid,@RequestParam("shopname") String shopname,@RequestParam("shopprice") String shopprice,@RequestParam("shopamount") String shopamount
     * @returnshopid,shopname,shopprice,shopamount
     */
    @PostMapping("/Insertshop")
    @ApiOperation(value = "增加商品信息", notes = "插入商品信息")
    @ResponseBody
    public int Insertshop( shop shop){
       shopService.Insertshop(shop); return 1;
    }

    /**
     * 通过商品编号删除数据
     * @param
     * @return
     */
    @PostMapping("/Deleteshop")
    @ApiOperation(value = "删除商品信息", notes = "根据商品Id信息")
    @ResponseBody
    public int Deleteshop(@RequestParam("shopid") Integer shopid){
        shopService.Deleteshop(shopid);return 1;
    }

    /**
     * 修改信息
     * @param
     * @return
     */
    @PostMapping("/Updateshop")
    @ApiOperation(value = "更新商品信息", notes = "根据商品Id修改信息")
    @ResponseBody
    public int Updateshop( shop shop) {
         shopService.Updateshop(shop);return 1;
    }

    /**
     * 显示所有数据
     * @return
     */

    @PostMapping("/ShowAllshop")
    @ApiOperation(value = "获取信息商品列表", notes = "获取所有商品信息")
    @ResponseBody
    public List<shop> ShowAllshop() {
        return shopService.ShowAllshop();
    }


    /**
     * 查询商品总数
     * @return
     */
    @PostMapping("/Totalshop")
    @ApiIgnore
    @ResponseBody
    public int Totalshop(){
        return shopService.Totalshop();
    };
}
